#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6+10;
int A[maxn];
int main() {
    int T; cin >> T;
    while(T--){
        int N; cin >> N;
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }
        int l = 0, r = 0;
        int ans = 0;
        set<int> s;
        while(r < N){
            while(r<N && !s.count(A[r])) s.insert(A[r++]);
            ans = max(ans, r - l);
            s.erase(A[l++]);
        }
        cout << ans << "\n";
    }
    return 0;
}
